#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <map>
#include <climits>

using namespace std;
struct Q{
    int a,b;
};
const int N=1e5+5;
int v[N];
int n,t;
int sum; //求逆序对的个数
Q q[N];

void helper(int L,int R,int mid){
    int vt[N];
    int k=0;
    int l=L;
    int r=mid+1;
    while(l<=mid && r<=R){
        if(v[l]<=v[r]){
            vt[k++]=v[l++];
        }else{
            sum+=mid-l+1;
            vt[k++]=v[r++];
        }
    }
    while(l<=mid) vt[k++]=v[l++];
    while(r<=R)  vt[k++]=v[r++];
    for(int i=L,j=0;i<=R;i++){
        v[i]=vt[j++];
    }
}


void Mergesort(int l,int r){
    if(l==r){
        return;
    }
    int mid=(l+r)/2;
    Mergesort(l,mid);
    Mergesort(mid+1,r);
    helper(l,r,mid);
    return;

}


int main(){
    //freopen("in.txt","r",stdin);
    cin >> n;
    for(int i=0;i<n;i++){
        cin  >> v[i];
    }
    int t;
    cin >> t;
    for(int i=0;i<t;i++){
        cin >> q[i].a >> q[i].b;
    }
    Mergesort(0,n-1);
    if(sum!=t){
        cout << "NO"<<endl;
        cout << (int)abs(t-sum) <<endl;
    }else{
        cout << "YES" <<endl;
    }

    return 0;
}